<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block</title>
</head>

<body>
<?php
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
//$sqlReport = "select distinct block_name as BName from tbl_lookup_location loc,tbl_dtls_q1_main main where main.district_id=".$distId." and loc.block_id = main.block_id order by block_name";
$sqlReport = "select distinct type_scheme from tbl_dtls_q1_main where district_id=".$distId;
//echo $sqlReport;
$queryReport = mysql_query($sqlReport);

?>
<table border="0" width="1023" cellspacing="0" cellpadding="0">
<tr>
<td height="19" bgcolor="#E9E9E9">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
    <font face="Verdana" color="#224568">Scheme wise block wise O&amp;M expenditure and cost of water supply</font></span>		</td>
</tr>

</table>


<table border="1" width="1023" cellspacing="0" cellpadding="0" height="49" bordercolor="#C5D8EB" style="border: 1px solid #BBD1E8" bgcolor="#C5D8EB"><tr>
<td width="93" align="center">
				<p align="center"><font face="Verdana" style="font-size: 8.5pt">
    <b>Type of Scheme</b> </font></td>
<td width="151" align="center">
				<p align="center"><font face="Verdana" style="font-size: 8.5pt">
    <b>Name of Block</b></font></td>
				<td width="153" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>Present Population (2010)</b></font></td>
				<td width="151" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>Quantity of water supplied (KLD)</b></font></td>
				<td width="151" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>O&M cost (Rs. lakhs/annum)</b></font></td>
				<td width="152" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Cost of water supply (Rs./KL)</b></font></td>
				<td width="156" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Per capita cost of supply/annum (Rs.)</b></font></td>
			</tr>
		
	
		
		
		<?php
			while($rowReport = mysql_fetch_array($queryReport)) {
			if($rowReport['type_scheme']!='RWSS')
			{
			$Total1=0;
			$Total2=0;
			$Total3=0;
			$Total4=0;
			$Total5=0;
			
		?>
			<tr bgcolor="#FFFFFF">
				
				<td align="center" width="93" valign="top"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReport['type_scheme']; ?></font></td>
				<td align="center" valign="top" colspan="6"><table border="1" width="100%" cellspacing="0" cellpadding="0" height="49" bordercolor="#C5D8EB" style="border: 1px solid #BBD1E8" bgcolor="#F9F9F9">
				<?php 
				//$sqlReportScheme="SELECT sum(main.`present_population`) population,main.`block_id`,sum(last.water_supply) water FROM `tbl_dtls_q1_main` main,tbl_dtls_q1_last last where main.`district_id` = ".$distId." and main.`type_scheme`='".$rowReport['type_scheme']."' and last.loc_id=main.id group by `block_id`"; 
				$sqlReportScheme="SELECT sum(main.`present_population`) population,main.`block_id`,sum(last.water_supply) water,sum(`mpc_9_10`)+sum(`mc_mr_9_10`)+sum(`mc_pr_9_10`)+sum(`pc_9_10`)+sum(`cc_9_10`) FY FROM `tbl_dtls_q1_main` main,tbl_dtls_q1_last last where main.`district_id` = ".$distId." and main.`type_scheme`='".$rowReport['type_scheme']."' and last.loc_id=main.id group by `block_id`";
				//echo $sqlReportScheme;
				$queryReportScheme = mysql_query($sqlReportScheme);
				while($rowReportScheme = mysql_fetch_array($queryReportScheme)) {
				
				//$Total1=0;
				$Total1+=$rowReportScheme['population']; 
				$Total2+=$rowReportScheme['water'];
				$Total3+=number_format($rowReportScheme['FY'],2,'.','');
				
				//$Total4+=$x;
				//$Total5+=$y;
				?>
				<tr>
				<td align="center" width="148"><font face="Verdana" style="font-size: 8.5pt"><?php echo getName('block',$rowReportScheme['block_id']);//$rowReportScheme['block_name']; ?></font></td>
				<td align="center" width="154"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReportScheme['population']; ?></font></td>
				<td align="center" width="151"><font face="Verdana" style="font-size: 8.5pt"><?php echo number_format($rowReportScheme['water'],2,'.',''); ?></font></td>
				<td align="center" width="151"><font face="Verdana" style="font-size: 8.5pt"><?php echo number_format($rowReportScheme['FY'],2,'.',''); ?></font></td>
				<td align="center" width="151"><font face="Verdana" style="font-size: 8.5pt">
				  <?php
				if($rowReportScheme['water']==0)
				{
				echo $x="0.00";
				}else{
				echo $x=number_format($rowReportScheme['FY']*100000/365/$rowReportScheme['water'],2,'.','');} ?>
				</font></td>
				<td align="center" width="155"><font face="Verdana" style="font-size: 8.5pt"><?php
				if($rowReportScheme['population']==0)
				{
				echo $y="0.00";
				}else{
				 echo $y=number_format($rowReportScheme['FY']*100000/$rowReportScheme['population'],2,'.','');} ?></font></td>
			</tr>
			<?php
			$Total4+=$x;
			$Total5+=$y;
			//$Total1+=$tot;
			 } 
			 
			 ?>
			</table></td></tr>
			 
			<tr>
				<td colspan="2" align="center" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b>Total</b></font></td>
				<td align="center" width="153" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo /*$Total1=TotPopulDistWise($distId,$rowReport['type_scheme']);*/ $Total1; ?></b></font></td>
				<td align="center" width="151" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo number_format($Total2,2,'.',''); ?></b></font></td>
				<td align="center" width="151" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo number_format($Total3,2,'.',''); ?></b></font></td>
				<td align="center" width="152" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php //echo $Total4; 
				if($Total2==0)
				{
				echo $x="0.00";
				}else{
				echo $x=number_format($Total3*100000/365/$Total2,2,'.','');}
				?></b></font></td>
				<td align="center" width="156" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php //echo $Total5; 
				if($Total1==0)
				{
				echo $x="0.00";
				}else{
				echo $x=number_format($Total3*100000/$Total1,2,'.','');}
				?></b></font></td>
			</tr>
			<?php 
			$GrandTotal1+=$Total1;
			$GrandTotal2+=$Total2;
			$GrandTotal3+=$Total3;
			$GrandTotal4+=$Total4;
			$GrandTotal5+=$Total5;
			} }?>
			
			<tr>
				<td colspan="2" align="center" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b>Grand Total</b></font></td>
				<td align="center" width="153" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo $GrandTotal1;?></b></font></td>
				<td align="center" width="151" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo number_format($GrandTotal2,2,'.','');?></b></font></td>
				<td align="center" width="151" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php echo number_format($GrandTotal3,2,'.','');?></b></font></td>
				<td align="center" width="152" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php //echo $GrandTotal4;
				if($GrandTotal2==0)
				{
				echo $x="0.00";
				}else{
				echo $x=number_format($GrandTotal3*100000/365/$GrandTotal2,2,'.','');}
				?></b></font></td>
				<td align="center" width="156" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><b><?php //echo $GrandTotal5;
				if($GrandTotal1==0)
				{
				echo $x="0.00";
				}else{
				echo $x=number_format($GrandTotal3*100000/$GrandTotal1,2,'.','');}
				?></b></font></td>
			</tr>
</td></tr>
		</table>
		<tr><td colspan="2"></td>
	<tr><td colspan="2"></tr>
</table>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>



</body>

</html>
